Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve failed evaluation detection, reporting #123

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

holyjak
Copy link
Member

@holyjak holyjak commented Sep 21, 2024

Issue: When we ask Wolfram to do something impossible, it typically returns the input form or $Failed, so it is hard to see what was wrong. However, when evaluated in a notebook, it does print an explanation. This is however ignored by the recommended .waitForAnswer.

Fix: Follow the docs and add a packet listener, which captures the messages we care about in these cases (text, message) between we start eval and read the result. To make this easier, move the impl. of evaluation into a new protocol method evaluate! + add extracting captured messages from the listener + throw an error if the result seems to indicate a problem.

Bonus: Upgrade Clojure to stable.

Demo

What does this look like?

(wl/eval "Subtract[1]")
Execution error (ExceptionInfo) at wolframite.impl.jlink_proto_impl.JLinkImpl/evaluate_BANG_ (jlink_proto_impl.clj:151).
Evaluation seems to have failed. Result: Subtract[1] Details: Subtract::argr: Subtract called with 1 argument; 2 arguments are expected.

(wl/eval "Get[\"/no-such-file\"]")
Execution error (ExceptionInfo) at wolframite.impl.jlink_proto_impl.JLinkImpl/evaluate_BANG_ (jlink_proto_impl.clj:151).
Evaluation seems to have failed. Result: $Failed Details: Get::noopen: Cannot open /no-such-file.

(wl/eval "Print[\"hello!\"]") ; => nil
[nREPL-session-101a2c04-a45a-4559-9cb5-319d8574a740] INFO wolframite.impl.jlink-proto-impl - Messages retrieved during evaluation: [hello!
]

@holyjak holyjak force-pushed the improve-error-handling-on-failed-eval branch 2 times, most recently from 1f4ba98 to 5c0f226 Compare September 22, 2024 10:46
Issue: When we ask Wolfram to do something impossible, it typically returns the input form or $Failed, so it is hard to see what was wrong. However, when evaluated in a notebook, it does print an explanation. This is however ignored by the recommended `.waitForAnswer`.

Fix: Follow the docs and add a packet listener, which captures the messages we care about in these cases (text, message) between we start eval and read the result. To make this easier, move the impl. of evaluation into a new protocol method `evaluate!` + add extracting captured messages from the listener + throw an error if the result seems to indicate a problem.

Bonus: Upgrade Clojure to stable.
@light-matters
Copy link
Contributor

Capturing errors is a great improvement. Should be mentioned in our upcoming talks.

@light-matters light-matters merged commit de93134 into main Sep 24, 2024
@light-matters light-matters deleted the improve-error-handling-on-failed-eval branch September 24, 2024 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants